﻿// //  ********************************************************************************
// //  Copyright (C) 2016 Sebastian Kenter. All rights reserved.
// // 
// //  Name    : PhotonServerProject | PhotonServerFramework | IServerTelegramHandler.cs
// //  Created : 2016 - 03 - 21 10:03
// //  Modified: 2016 - 04 - 18 09:38
// //  ********************************************************************************

using System;
using ExitGames.Logging;
using PhotonServerCommon.Enums;
using PhotonServerFramework.Interfaces.Telegram;

namespace PhotonServerFramework.Interfaces.Handler
{
    /// <summary>
    ///     Interface for a client telegram handler
    /// </summary>
    /// <typeparam name="TPeer">Type of the peer (normally IServerPeer)</typeparam>
    public interface IServerTelegramHandler<in TPeer>
    {
        /// <summary>
        ///     Logger instance
        /// </summary>
        ILogger Logger { get; }

        /// <summary>
        ///     Unique handler id
        /// </summary>
        Guid HandlerId { get; set; }

        /// <summary>
        ///     Handler type (Request, Response or Event)
        /// </summary>
        HandlerTypes HandlerType { get; }

        /// <summary>
        ///     OperationCode that the handler can handle
        /// </summary>
        byte HandlerCode { get; }

        /// <summary>
        ///     OperationSubCode that the handler can handle
        /// </summary>
        int HandlerSubCode { get; }

        /// <summary>
        ///     Tries to handle the incoming telegram from the given TPeer (normally IServerPeer)
        /// </summary>
        /// <param name="telegram">The telegram to be handled</param>
        /// <param name="serverPeer">The peer requesting the handling</param>
        /// <returns>true if handled, otherwise false</returns>
        bool HandleTelegram(ITelegram telegram, TPeer serverPeer);
    }
}
